# ifndef PRE
# define PRE

/**
  \brief: Configuraciones necesarias para la Ejecucion del Preprocesamiento

  @author: Typson Sánchez
  */

# define ID 0
# define IDCARRERA 1
# define NS 2
# define UNI 3
# define NONBRECARRERA 4
# define PROM 5
# define INDICE 6
# define N 7
# define CE 8
# define NE 9
# define COR1 10
# define COR2 11
# define CORCA1 12
# define CORCA2 13
# define INDICEUNI 14
# define DURACIONPROM 15

// Declaraciones de Variable a Manipular y las Por Defecto

std::string command_line;

std::string input_file_name = "pre-1.txt";
std::string input_file_students;
std::string input_file_careers;
std::string output_file_name;
std::string mediana_prom;
std::string mediana_indice;
std::string filtros [10];

int filtros_indice  [10];
float desviProm = 0,desviIndice = 0;

int count_men= 0;

static char * hello =
"\n"
"Preprocessing of the AYDA project\n"
"Copyright (C) 2012 University of Los Andes (ULA)\n"
"Merida - REPÚBLICA BOLIVARIANA DE VENEZUELA\n"
"ULA Computer Science Department\n"
"This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
"or FITNESS FOR A PARTICULAR PURPOSE\n"
"\n";

static char doc[] = "pre -- Preprocessing of the project";

static char argDoc[] = "-F<file-students> -U<archivo-carreras> [-o<archivo-salida>]\n [-f<archivo-entrada>] [parámetros-coste | filtros] [-o<archivo-salida>]";

const char *argp_program_version =
"pre 0.6.3\n"
"Preprocessing of the AYDA project\n"
"Copyright (C) 2012 UNIVERSITY of LOS ANDES (ULA)\n"
"Merida - REPÚBLICA BOLIVARIANA DE VENEZUELA\n"
"ULA Computer Science Department\n"
"This is free software; There is NO warranty; not even for MERCHANTABILITY\n"
"or FITNESS FOR A PARTICULAR PURPOSE\n"
"\n";


//Variables con el valor por defecto

                    /* Estos son los valores de los parametros */
// El Valor del Parametro ALPHA
float ALFA    = 1;
// El Valor del Parametro BETA
float BETA    = 1;
// El Valor del Parametro DELTA
float DELTA   = 1;
// El Valor del Parametro EPSILON
float EPSILON = 1;
// El Valor del Parametro GAMMA
float GAMMA   = 1;
// El Valor del Parametro KAPPA
float KAPPA   = 1;
// El Valor del Parametro LAMBDA
float LAMBDA  = 1;
// El Valor del Parametro THETA
float THETA   = 1;

// Declaracion de las Banderas

static struct argp_option options [] = {
  {"intentos"   , '#', "# of applications"    , OPTION_ARG_OPTIONAL,"Filtering number of applications", 0 },
  {"alfa"       , 'a', "value of alfa"        , OPTION_ARG_OPTIONAL,"Value of the parameter Alfa", 0 },
  {"beta"       , 'b', "value of beta"        , OPTION_ARG_OPTIONAL,"Value of the parameter Beta", 0 },
  {"carrera"    , 'C', "name of carrer"       , OPTION_ARG_OPTIONAL,"Filtering career name", 0 },
  {"delta"      , 'd', "value of delta"       , OPTION_ARG_OPTIONAL,"Value of the parameter Delta", 0 },
  {"condicion-especial", 'D',"special condition", OPTION_ARG_OPTIONAL,"Filtered by special conditions", 0 },
  {"epsilon"    , 'e', "value of epsilon"     , OPTION_ARG_OPTIONAL,"Value of the parameter Epsilon", 0 },
  { 0           , 'f', "<input-file>"         , OPTION_ARG_OPTIONAL,"File path and name of input", 0 },
  { 0           , 'F', "<students-file>"      , OPTION_ARG_OPTIONAL,"File path and name of students", 0 },
  {"gamma"      , 'g', "value of gamma"       , OPTION_ARG_OPTIONAL,"Value of the parameter Gamma", 0 },
  {"id-carrera" , 'i', "career id"            , OPTION_ARG_OPTIONAL,"Filtering by career id", 0 },
  {"indice"     , 'I', "GPA"                  , OPTION_ARG_OPTIONAL,"Grade point index filtering", 0 },
  {"kappa"      , 'k', "value of kappa"       , OPTION_ARG_OPTIONAL,"Value of the parameter Kappa", 0 },
  {"lambda"     , 'l', "value of lambda"      , OPTION_ARG_OPTIONAL,"Value of the parameter Lambda", 0 },
  {"nivel"      , 'n', "socioeconomic status" , OPTION_ARG_OPTIONAL,"Filter by socioeconomic status" , 0 },
  { 0           , 'o', "<output-file>"        , OPTION_ARG_OPTIONAL,"File path and name of output" , 0 },
  {"Opcion"     , 'O', "# intents"            , OPTION_ARG_OPTIONAL,"Filtering attempts quantities of quota allocation in college." , 0 },
  {"promedio"   , 'p', "average"              , OPTION_ARG_OPTIONAL,"GPA filtering" , 0 },
  {"estudiante" , 's', "range of student id"  , OPTION_ARG_OPTIONAL,"Range by the student's id" , 0 },
  {"seleccion"  , 'S', "rank chosen career id", OPTION_ARG_OPTIONAL,"Rank chosen career by id" , 0 },
  {"theta"      , 't', "value of theta"       , OPTION_ARG_OPTIONAL,"Value of the parameter Theta" , 0 },
  { 0           , 'U', "<careers-file>"       , OPTION_ARG_OPTIONAL,"File path and name of careers" , 0 },
  {"universidad", 'u', "name of university"   , OPTION_ARG_OPTIONAL,"Filter by name of the university" , 0 },
  {"version"    , 'V', 0                      , OPTION_ARG_OPTIONAL,"Print version information and then exit", 0},
  { 0, 0, 0, 0  , 0, 0 }
  };
  
// Comportamineto de la Banderas
static error_t parser_opt(int key, char *arg, struct argp_state *) {
  switch (key) {
    case '#':
      if (arg != NULL){
        filtros [9] = arg;
        filtros_indice [9] = 9;
      }
      else{
        ERROR("Waiting for intents per year for input in command line");
      }
      break;
    case 'a':
      if (arg == NULL)
        ERROR("Waiting for value of parameter alfa in command line");
      ALFA = atof(arg);
      break;
    case 'b':
      if (arg == NULL)
        ERROR("Waiting for value of parameter beta in command line");
      BETA = atof(arg);
      break;
    case 'C':
      if (arg != NULL){
        filtros [4] = arg;
        filtros_indice [4] = 4;
      }
      else{
        ERROR("Waiting for name of career for input in command line");
      }
      break;
    case 'd':
      if (arg == NULL)
        ERROR("Waiting for value of parameter delta in command line");
      DELTA = atof(arg);
      break;
    case 'D':
      if (arg != NULL){
        filtros [8] = arg;
        filtros_indice [8] = 8;
      }
      else{
        ERROR("Waiting for intents for input in command line");
      }
      break;
    case 'e':
      if (arg == NULL)
        ERROR("Waiting for value of parameter alfa in command line");
      EPSILON = atof(arg);
      break;
    case 'f':
      if (arg == NULL)
        ERROR("Waiting for name of students file for input in command line");
      input_file_name = arg;
      break;
    case 'F':
      if (arg == NULL)
        ERROR("Waiting for name of students file for input in command line");
      input_file_students = arg;
      break;
    case 'g':
      if (arg == NULL)
        ERROR("Waiting for value of parameter gamma in command line");
      GAMMA = atof(arg);
      break;
    case 'i':
      if (arg != NULL){
        filtros [1] = arg;
        filtros_indice [1] = 1;
      }
      else{
        ERROR("Waiting for career id for input in command line");
      }
      break;
    case 'I':
      if (arg != NULL){
        filtros [6] = arg;
        filtros_indice [6] = 6;
      }
      else{
        ERROR("Waiting for indice academico for input in command line");
      }
      break;
    case 'k':
      if (arg == NULL)
        ERROR("Waiting for value of parameter kappa in command line");
      KAPPA = atof(arg);
      break;
    case 'l':
      if (arg == NULL)
        ERROR("Waiting for value of parameter lambda in command line");
      LAMBDA = atof(arg);
      break;
    case 'n':
      if (arg != NULL){
        filtros [2] = arg;
        filtros_indice [2] = 2;
      }
      else{
        ERROR("Waiting for socioeconomic for input in command line");
      }
      break;
    case 'o':
      if (arg != NULL)
        output_file_name = arg;
      break;
    case 'O':
      if (arg != NULL){
        filtros [7] = arg;
        filtros_indice [7] = 7;
      }
      else{
        ERROR("Waiting for intents for input in command line");
      }
      break;
    case 'p':
      if (arg != NULL){
        filtros [5] = arg;
        filtros_indice [5] = 5;
      }
      else{
        ERROR("Waiting for promedio for input in command line");
      }
      break;
    case 's':
      if (arg != NULL){
        cout << arg;
        filtros [0] = arg;
        filtros_indice [0] = 0;
      }
      else{
        ERROR("Waiting for id of student for input in command line");
      }
      break;
    case 'S':
      if (arg != NULL){
        filtros [1] = arg;
        filtros_indice [1] = 1;
      }
      else{
        ERROR("Waiting for id of career selected for input in command line");
      }
      break;
    case 't':
      if (arg == NULL)
        ERROR("Waiting for value of parameter theta in command line");
      THETA = atof(arg);
      break;
    case 'u':
      if (arg != NULL){
        filtros [3] = arg;
        filtros_indice [3] = 3;
      }
      else{
        ERROR("Waiting for name of university for input in command line");
      }
      break;
    case 'U':
      if (arg == NULL)
        ERROR("Waiting for name of careers file for input in command line");
      input_file_careers = arg ;
      break;
    case 'V':
      cout << argp_program_version;
      exit(0);
      break;
  };
  return 0;
}

// Struct para definir la recepcion de los parametross
static struct argp argDefs = { options, parser_opt, argDoc, doc, 0, 0, 0 };

# endif